//
//  StarPredictCell.m
//  LiveStar
//
//  Created by 漪珊 on 2016/12/12.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "StarPredictCell.h"
#import "PredictListModel.h"

@implementation StarPredictCell
- (void)awakeFromNib {
    [super awakeFromNib];
    kButtonRadius(self.predictBtn, self.predictBtn.height/2);
    self.predictTime.layer.borderColor = [UIColor blackColor].CGColor;
    self.predictTime.layer.borderWidth = 0.5;
}

- (void)setPredictListModel:(PredictListModel *)predictListModel {
    _predictListModel = predictListModel;
    [self.predictImg sd_setImageWithURL:[NSURL URLWithString:predictListModel.s_image] placeholderImage:kPLACE_MID];
    self.predictStarName.text = predictListModel.s_name;
    if ([predictListModel.l_gift integerValue]) {//有礼物
        self.predictGitTip.hidden = YES;
    } else {
        self.predictGitTip.hidden = NO;
    }
    
    if ([predictListModel.l_package integerValue]) {//有红包
        self.predictRedPaperTip.hidden = YES;
    } else {
        self.predictGitTip.hidden = NO;
    }
    [self.predictNum setTitle:[NSString stringWithFormat:@"%@人预选",KString(predictListModel.l_booked)] forState:UIControlStateNormal];
    NSString *dateStr = [NSString stringWithFormat:@"%@ %@",predictListModel.l_date,predictListModel.l_startime];
    NSDateFormatter *inputFormatter = [[NSDateFormatter alloc] init];
    [inputFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    NSDate* inputDate = [inputFormatter dateFromString:dateStr];
    [inputFormatter setDateFormat:@"yyyy年MM月dd日 HH:mm开播"];
    self.predictTime.text = [inputFormatter stringFromDate:inputDate];
    
    if ([predictListModel.booked integerValue] == 20) {//未订阅
        [self.predictBtn setTitle:@"+ 订阅" forState:UIControlStateNormal];
        self.predictBtn.backgroundColor = HESHEX_COLOR(@"04DD98");
        [self.predictBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    } else {//已订阅
        [self.predictBtn setTitle:@"已订阅" forState:UIControlStateNormal];
        self.predictBtn.backgroundColor = [UIColor whiteColor];
        [self.predictBtn setTitleColor:HESHEX_COLOR(@"04DD98") forState:UIControlStateNormal];
    }
}

#pragma mark -- 预选
- (IBAction)PrdictClick:(id)sender {
    if ([self.delegate respondsToSelector:@selector(PredictLivingWithCell:)]) {
        [self.delegate PredictLivingWithCell:self];
    }
}

@end
